#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	string file, line;
	cout << "enter filename: ";
	cin >> file;
	ifstream fin;
	fin.open(file);

	int sum = 0;
	while (getline(fin, line)){
		istringstream ss(line);
		string word;
		while (getline(ss, word, ' ')){
			sum++;
		}
	}
	cout << file << " contains " << sum << " whitespace separated words" << endl;

	system("pause");
	return 0;
}